//
//  HShowAlertUtils.m
//  项目二
//
//  Created by rimi on 16/5/26.
//  Copyright © 2016年 objective. All rights reserved.
//

#import "HShowAlertUtils.h"

@implementation HShowAlertUtils
+ (void)showAlertWithMessage:(NSString *)message cancelAction:(void (^)  ())cancelAction commitAction:(void (^)())commitAction{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Info" message:message preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:@"Info" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        if (cancelAction) {
            cancelAction();
        }
    }]];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"next" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (cancelAction) {
            cancelAction();
        }
    }]];
    
    UIViewController *rootVC = [[[UIApplication sharedApplication]keyWindow]rootViewController];
    [rootVC presentViewController:alert animated:YES completion:nil];
}

+ (void)showAlertWithmessage:(NSString *)message viewController:(UIViewController *)VC{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Info" message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alert addAction:action];
    [VC presentViewController:alert animated:YES completion:nil];
}
@end
